#!/bin/bash
read -t 10 -p "do you want uninstll nginx & php: " do_uninstall;
if [[ "${do_uninstall}" == "y" ]];then
    sudo apt-get remove --purge nginx -y;
    sudo apt-get --purge remove nginx-common -y;
    sudo apt-get --purge remove php* -y;
    sudo apt-get autoremove -y;
fi;

sudo apt install nginx -y;
sudo apt-get install  php-fpm php-cli php-curl php-gd php-cgi -y;


sudo cp nginx_default /etc/nginx/sites-available/default;

whoname=`whoami`
sudo rm -rf  /var/www/html/dashboard;
sudo mkdir -p /var/www/html/dashboard;
cd  /var/www/html/dashboard;
sudo git clone https://gitee.com/team_space/pi-dashboard.git .;
sudo chown -R ${whoname} /var/www/html/dashboard;
sudo systemctl restart nginx;
sudo systemctl enable nginx;

